package com.cwz.admin.controller;

import com.cwz.admin.entity.admin;
import com.cwz.admin.service.admin.adminService;
import com.cwz.admin.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@Configuration
public class adminController {
    @Autowired
    private adminService adminService;

//    @GetMapping("findAdminByID")
//    public admin findAdminByID(Integer id){
//        return adminService.adminFindCommodityByID(id);
//    }

    /**
     * 修改密码
     * @param admin
     * @return
     */
    @PutMapping("updAdminByID")
    public int updAdminByID(admin admin){
        String pwd = SecurityUtils.sha256Hex(admin.getPwd());
        admin.setPwd(pwd);
        return adminService.adminUpdCommodity(admin);
    }
}
